package util;

import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class WindowMove {
    private static double xOffset = 0;
    private static double yOffset = 0;
    public static void setMoveMode(Stage primaryStage,Pane root){
        root.setOnMousePressed(event -> {
            xOffset = event.getSceneX();
            yOffset = event.getSceneY();
        });
        //监听了鼠标按下和拖动事件，通过计算偏移量来更新窗口的位置
        root.setOnMouseDragged(event -> {
            primaryStage.setX(event.getScreenX() - xOffset);
            primaryStage.setY(event.getScreenY() - yOffset);
        });
    }
}
